const ENUM = new Map([
    [
        'yesNo',
        [
            {name: '是', value: true},
            {name: '否', value: false},
        ]
    ],
    [
        'status',
        [
            {name: '启用', value: 'ENABLE'},
            {name: '禁用', value: 'DISABLE'},
            {name: '锁定', value: 'LOCKED'},
        ]
    ],
    [
        'enabled',
        [
            {name: '启用', value: true},
            {name: '禁用', value: false},
        ]
    ],
    [
        'sex',
        [
            {name: '男', value: 'MALE'},
            {name: '女', value: 'FEMALE'},
            {name: '未知', value: 'UNKNOWN'},
        ]
    ],
    [
        'authorizedGrantType',
        [
            {name: '密码', value: 'password'},
            {name: '刷新token', value: 'refresh_token'},
            {name: '授权码', value: 'authorization_code'},
            {name: '手机验证码', value: 'sms_code'},
            {name: '邮箱验证码', value: 'mail_code'},
            {name: '绑定授权', value: 'bind_code'},
            {name: '客户端', value: 'client_credentials'},
            {name: '令牌交换', value: 'urn:ietf:params:oauth:grant-type:token-exchange'},
            {name: '设备编码', value: 'urn:ietf:params:oauth:grant-type:device_code'},
            {name: 'JWT', value: 'urn:ietf:params:oauth:grant-type:jwt-bearer'},
        ]
    ],
    [
        'authenticationMethod',
        [
            {name: 'basic认证', value: 'client_secret_basic'},
            {name: 'post表单', value: 'client_secret_post'},
            {name: 'HMAC JWT', value: 'client_secret_jwt'},
            {name: '私密JWT', value: 'private_key_jwt'},
            {name: 'CA证书', value: 'tls_client_auth'},
            {name: '自签名', value: 'self_signed_tls_client_auth'},
        ]
    ],
    [
        'requestMethod',
        [
            {name: 'GET', value: 'GET'},
            {name: 'POST', value: 'POST'},
            {name: 'PUT', value: 'PUT'},
            {name: 'DELETE', value: 'DELETE'},
            {name: 'PATCH', value: 'PATCH'},
        ]
    ],
    [
        'result',
        [
            {name: '成功', value: true},
            {name: '失败', value: false},
        ]
    ],
    [
        'region',
        [
            {name: '华东', value: "EAST_CHINA"},
            {name: '华北', value: "NORTH_CHINA"},
            {name: '华南', value: "SOUTH_CHINA"},
            {name: '北美', value: "NORTH_AMERICA"},
            {name: '东南亚', value: "SOUTHEAST_ASIA"},
        ]
    ],
    [
        'auditStatus',
        [
            {name: '新建', value: 'NEW_BUILT'},
            {name: '待审核', value: 'UN_AUDITED'},
            {name: '已审核', value: 'AUDITED'},
            {name: '已驳回', value: 'REJECTED'},
        ]
    ],
    [
        'resourceType',
        [
            {name: '按钮', value: 'BUTTON'},
            {name: 'API', value: 'API'},
        ]
    ],
    [
        'bindType',
        [
            {name: '微信公众号', value: 'MP'},
            {name: '微信小程序', value: 'MA'},
            {name: '企业微信', value: 'CP'},
        ]
    ],
    [
        'ossType',
        [
            {name: 'minio', value: 'MINIO'},
            {name: '阿里云', value: 'ALIYUN'},
            {name: '七牛云', value: 'QINIU'},
        ]
    ],
    [
        'smsType',
        [
            {name: '阿里云', value: 'ALIYUN'},
            {name: '七牛云', value: 'QINIU'},
            {name: '麦讯通', value: 'MXTONG'},
            {name: '凌凯', value: 'LINGKAI'},
        ]
    ],
    [
        'vodType',
        [
            {name: '阿里云', value: 'ALIYUN'},
        ]
    ],
    [
        'command',
        [
            {name: '心跳检测', value: 'HEARTBEAT'},
            {name: '直发消息', value: 'DIRECT_MSG'},
            {name: '系统通知', value: 'SYS_NOTICE_MSG'},
            {name: '群聊消息', value: 'GROUP_CHAT_MSG'},
            {name: '群聊通知', value: 'GROUP_CHAT_NOTICE_MSG'},
            {name: '好友聊天', value: 'FRIEND_CHAT_MSG'},
            {name: '加好友消息', value: 'ADD_FRIEND_MSG'},
            {name: '离线直发消息', value: 'OFFLINE_DIRECT_MSG'},
            {name: '离线好友聊天消息', value: 'OFFLINE_FRIEND_CHAT_MSG'},
            {name: '离线加好友消息', value: 'OFFLINE_ADD_FRIEND_MSG'},
        ]
    ],
    [
        'subMsgType',
        [
            {name: '访问token过期', value: 'ACCESS_TOKEN_EXPIRED'},
            {name: '刷新角色权限', value: 'REFRESH_ROLE_PERMISSION'},
            {name: '刷新按钮权限', value: 'REFRESH_BUTTON_PERMISSION'},
        ]
    ],
    [
        'certType',
        [
            {name: 'API签名', value: 'API_SIGN'},
        ]
    ],
    [
        'yesNo',
        [
            {name: '是', value: true},
            {name: '否', value: false},
        ]
    ],
    [
        'flowModelStatus',
        [
            {name: '待发布', value: 'TO_BE_PUBLISHED'},
            {name: '已发布', value: 'PUBLISHED'},
            {name: '已停用', value: 'DISABLED'},
        ]
    ],
    [
        'flowFormType',
        [
            {name: '无表单', value: 'NONE'},
            {name: '表单', value: 'FORM'},
            {name: '自定义', value: 'CUSTOM'},
            {name: '固定格式', value: 'FIXED'},
        ]
    ],
]);

// 根据关键值寻找枚举值 返回一个对象
export const getMapValue = (key, value) => {
    if (!ENUM.has(key)) {
        throw new Error(`在枚举值中 找不到${key}值`);
    }
    const arr = ENUM.get(key);
    const [data] = arr.filter((item) => (item.value + '' === value + ''))
    return data ? data : {}
}


/* 根据枚举值关键值寻找 */
export const getMapItems = (key) => {
    if (!ENUM.has(key)) {
        throw new Error(`在枚举值中 找不到${key}值`);
    }
    return ENUM.get(key)
}
